package net.tngou.iask.service;



import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.math.NumberUtils;

import net.tngou.iask.dao.DiseaseDao;
import net.tngou.iask.jdbc.PageUtil;
import net.tngou.iask.jdbc.QueryHelper;
import net.tngou.iask.pojo.Agerange;
import net.tngou.iask.pojo.Department;
import net.tngou.iask.pojo.Disease;
import net.tngou.iask.pojo.POJO;
import net.tngou.iask.pojo.Place;
import net.tngou.iask.pojo.Treatment;
import net.tngou.iask.util.StringUtil;

/**
 * 疾病
 * @author tngou@tngou.net
 *
 */
public class DiseaseService extends BaseService {
	
	
	
	/**
	 * 取得疾病
	 * @param page 当前页
	 * @param size 页大小
	 * @param main 实体
	 * @param keyword 关键词
	 * @return
	 */
	public PageUtil getPage(int page,int size,long main,String keyword) {
		DiseaseDao dao = new DiseaseDao();
		return dao.getPage(page, size, main, keyword);
	}
	public PageUtil getNotDisease(int page,int size,long main,String keyword) {
		DiseaseDao dao = new DiseaseDao();
		return dao.getNotDisease(page, size, main, keyword);
	}
	public PageUtil getPage(int page,int size,long main,long survey,String keyword) {
		DiseaseDao dao = new DiseaseDao();
		return dao.getPage(page, size, main, survey, keyword);
	}
	
	/**
	 * 取得疾病对应的身体位置
	 * @param disease 疾病ID
	 * @return
	 */
	public List<Place> getPlace(long disease) {
		DiseaseDao dao = new DiseaseDao();
		return dao.getPlace(disease);	
	}
	
	/**
	 * 取得疾病对应的就诊科室
	 * @param disease  疾病ID
	 * @return
	 */
	public List<Department> getDepartment(long disease) {
		DiseaseDao dao = new DiseaseDao();
		return dao.getDepartment(disease);	
	}
	
	/**
	 * 取得疾病对应的治疗方式
	 * @param disease  疾病ID
	 * @return
	 */
	public List<Treatment> getTreatment(long disease) {
		DiseaseDao dao = new DiseaseDao();
		return dao.getTreatment(disease);		
	}
	
	/**
	 * 取得疾病对应的年龄段
	 * @param disease  疾病ID
	 * @return
	 */
	public List<Agerange> getAgerange(long disease) {
		DiseaseDao dao = new DiseaseDao();
		return dao.getAgerange(disease);	
	}
	/**
	 * 更新疾病对应的关系表
	 * @param disease  疾病id
	 * @param place	身体部位
	 * @param agerange 年龄段
	 * @param treatment 治疗方式
	 * @param department 科室
	 */
	public void update(long disease,String[] place,String[] agerange ,String[] treatment,String[] department) {
		Long places[]=null;
		Long ageranges[]=null;
		Long treatments[]=null;
		Long departments[]=null;
		if(place!=null)
		{
			places= StringUtil.StringToLong(place) ;;
		}
		if(agerange!=null)
		{			
			ageranges= StringUtil.StringToLong(agerange) ;
		}
		if(treatment!=null)
		{		
			treatments= StringUtil.StringToLong(treatment) ;
		}
		if(department!=null)
		{		
			departments= StringUtil.StringToLong(department) ;
		}
		DiseaseDao dao = new DiseaseDao();
		dao.update(disease, places, ageranges, treatments, departments);
	}
	
	/**
	 * 取得疾病列表
	 * @param main 实体（）
	 * @return
	 */
	public List<Map<String, Object>>  getList(long main) {
		DiseaseDao dao = new DiseaseDao();
		return dao.getList(main);
	}
	
	/**
	 * 取得问卷关联的疾病
	 * @param survey 文件
	 * @return
	 */
	public List<Map<String, Object>> getDisease(long survey) {
		DiseaseDao dao = new DiseaseDao();
		return dao.getDisease(survey);
	}
	public List<Map<String, Object>> getList(long main,long patient) {
		DiseaseDao dao = new DiseaseDao();
		return dao.getList(main, patient);
	}
	
}
